import 'package:flutter/material.dart';

class SheetElement extends StatefulWidget {
  // 传入参数
  const SheetElement({
    Key? key,
    this.title = '标题',
    this.titleStyle,
    this.desc,
    this.descStyle,
    this.showBase = true,
    required this.onTap,
  }) : super(key: key,);
  final String title;
  final TextStyle? titleStyle;
  final String? desc;
  final TextStyle? descStyle;
  final bool showBase;
  final VoidCallback onTap;

  @override
  State<StatefulWidget> createState() => SheetElementState();

}

class SheetElementState extends State<SheetElement> {


  @override
  Widget build(BuildContext context) {
    var ew = MediaQuery.of(context).size.width * 0.01;
    return InkWell(
      onTap: (){widget.onTap();},
      child: Container(
          width: MediaQuery.of(context).size.width * 0.9,
          height: ew * 18,
          padding: EdgeInsets.fromLTRB(ew * 3, ew * 3, ew * 3, ew * 3),
          decoration: widget.showBase?const BoxDecoration( border:  Border(bottom:BorderSide(width: 1,color: Color(0xffe5e5e5)) ),):null,
          child: Center(
              child: Column(
                children: [
                  Text(widget.title,style: widget.titleStyle??TextStyle(color: Colors.black87,fontSize: widget.desc != null?ew * 5:ew * 6)),
                  widget.desc != null?Text(widget.desc??'',style: widget.descStyle??TextStyle(color: Colors.black26,fontSize: ew * 3)):
                  const SizedBox(),
                ],
              )
          )
      ),
    );
  }


}